import axios from 'axios'
const axiosInstance = axios.create({
    baseURL:'http://localhost:8000'
})
axiosInstance.interceptors.response.use(
    (response)=>{
        //response响应对象 data,headers
        //response.data.success为true表示成功，false表示失败
        if(response.data && response.data.success){
            return response.data//返回响应体，这样的话就可以在代码直接获取响应体
        }else{
            throw new Error(response.data.message || '服务器错误')
        }
    },
    (error)=>{
        console.log('错误',error);
        throw error
        
    }
)

export default axiosInstance